package com.siki.vo.enterprise;


import com.siki.pojo.commonEntity.SysUser;
import com.siki.pojo.enumeration.common.AuditStatus;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.Optional;

/**
 * @Author Siki
 * @Date 2020/6/12
 */
@ApiModel("企业用户信息返回VO")
@Getter
@Setter
@NoArgsConstructor
public class EnterpriseUserInfoVO {
    @ApiModelProperty("企业名称")
    String realName;

    @ApiModelProperty("审核状态")
    String auditStatus;

    @ApiModelProperty(value = "企业所在地址")
    String address;

    @ApiModelProperty(value = "企业邮箱")
    String email;

    @ApiModelProperty(value = "头像url")
    String avatarUrl;

    @ApiModelProperty(value = "公司介绍")
    String introduction;

    public EnterpriseUserInfoVO(SysUser users){
        Optional.ofNullable(users).ifPresent(user->{
            this.realName= user.getRealName();
            this.auditStatus = Optional.ofNullable(user.getAuditStatus())
                    .map(AuditStatus::getName).orElse(null);
            Optional.ofNullable(user.getEnterprise()).ifPresent(enterprise -> {
                this.address = enterprise.getAddress();
                this.email = enterprise.getEmail();
                this.avatarUrl = enterprise.getAvatarUrl();
                this.introduction = enterprise.getIntroduction();
            });
        });
    }
}
